home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / ws87.p < prev    next >
Encoding:
Text File  |  1987-08-10  |  1.0 KB  |  46 lines

  1. PROGRAM Ws87;
  2.     {
  3.     **********************************************************************
  4.     Copy an 8-bit file  to a 7-bit file,  turning characters with bit  8
  5.     set into 4-character octal escape sequences \nnn.  This is useful in
  6.     analyzing WordStar microcomputer word processor files.
  7.  
  8.     Usage:
  9.  
  10.     @WS87
  11.     Old 8-bit file: filespec
  12.     New 7-bit file: filespec
  13.  
  14.     [10-Oct-85]
  15.     **********************************************************************
  16.     }
  17. VAR
  18.     fp8,fp7 : PACKED FILE OF integer;
  19. BEGIN
  20. Rewrite(output,'tty:');
  21. Write('Old 8-bit file: ');
  22. Reset(fp8,'':@,'/e/b:8');
  23. Write('New 7-bit file: ');
  24. Rewrite(fp7,'':@,'/e/b:7');
  25. WHILE NOT Eof(fp8) DO
  26.     BEGIN
  27.     IF fp8^ > 127 THEN
  28.     BEGIN
  29.         fp7^ := ord('\');
  30.         Put(fp7);
  31.         fp7^ := (fp8^ DIV 64) + ord('0');
  32.         Put(fp7);
  33.         fp7^ := ((fp8^ DIV 8) MOD 8) + ord('0');
  34.         Put(fp7);        
  35.         fp7^ := (fp8^ MOD 8) + ord('0');
  36.         Put(fp7)
  37.     END
  38.     ELSE
  39.     BEGIN
  40.     fp7^ := fp8^;
  41.         Put(fp7)
  42.     END;
  43.     Get(fp8)
  44.     END;
  45. END.
  46.